class ReportController < ApplicationController
  
  def index
    Dir["#{RAILS_ROOT}/lib/semaphor/reports/**/*.rb"].sort.each { |lib| require lib }
    require 'semaphor/reports/top_uri'
    
    db = db_connection
    @table_info = db.select_one("SHOW TABLE STATUS LIKE 'hits'")
    @start_date = db.select_value("SELECT MIN(created_at) FROM hits")
    @end_date = db.select_value("SELECT MAX(created_at) FROM hits")
  end
  
  def run
    @report = params['class'].constantize.new
    @report.run
    
    @title = @report.class.name
    puts @report.class.metadata.inspect
    render :action => "report_#{@report.class.template}"
  end
  
end
